
<?php $this->JQuery()->javascriptCaptureStart() ?>
$(document).ready(function() {
    $('#translations input[type="text"]').each(function() {
        $(this).blur(function() {
            if ($(this).attr('prev') !== $(this).attr('value')) {
                $.post(
                    '<?php echo $this->geturl('edit','translate', null, 'admin1')?>',
                    {id:$(this).attr('rel'), val:escape($(this).attr('value')), loc:escape($(this).attr('locale'))}
                );
            }
        });
    });
});
<?php $this->JQuery()->javascriptCaptureEnd() ?>

<?php $this->headStyle()->captureStart()?>
    #content td { padding:5px}
    #content table { border:1px #aaa solid; padding:5px; width:100%}
    #content th {font-weight:bold;}
    #content .page a {padding:2px;}
<?php $this->headStyle()->captureEnd()?>
<form method="get" name="company_form">
    <a href="<?php echo $this->geturl('add','company', null, 'admin1')?>">Add</a>
    Keyword : <input type="text" name="company" id="search" value="<?php if (!empty($_GET['company'])) { echo $_GET['company']; }?>"/>
    <input type="submit" name="search_btn" id="search_btn" value="Search"/>
    <?php if (!empty($_GET['company'])) { ?>
        <a href="<?php echo $this->geturl('list','company', null, 'admin1')?>">View All</a>
    <?php } ?>
</form>
<table border="1" id="listings">
<?php
    $get = $_GET; unset($get['page']);
    $pagination = $this->pagination($this->listing_number, $this->page, 15, 4, $this->geturl('list', 'company', null, 'admin1', $get));
?>
<?php if($this->listing_number == 0):?>
	No Companies are defined
<?php else:?>
    <tr>
        <th>
            Company Name
        </th>
        <th>
            Creation date
        </th>
        <th>
            Status
        </th>
   </tr>
    <?php foreach ($this->list as $item):?>
    <?php 
		$email = Model_User::one(array('cid' => new MongoId($item->id))); 
		if(empty($email->username)){
			continue;
		}
	?>
        <tr>
            <td>
            	<?php if(!empty($item->username)):?>
                <a href="<?php echo $this->geturl('display', 'company', null, 'admin1', array('id'=> $item->id))?>" target="_blank">
                    <?php echo $item->username; ?>
                </a>
                <?php else:?>
                	<?php 
					if($email){
						echo !empty($email->em) ? $email->em : "";
					}
					?>
                <?php endif;?>
            </td>
            <td>
                <?php if (!empty($item->created_at)) {echo date (MEDIUM_DATE_FORMAT, strtotime($item->created_at));}?>
            </td>
            <td>
                <?php echo $item->status;
				//print_r($item);
				?>
            </td>
        </tr>
    <?php 
    endforeach; 
endif;
?>
</table>
<?php echo $pagination;?>
